package com.zwk.gulimall.ware.advice;

import com.zwk.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestControllerAdvice("com.zwk.gulimall.ware.controller")
public class WareControllerException {
    /**
     * ExceptionHandler:指定捕捉的异常
     *
     * @param e
     * @return
     */
    @ExceptionHandler(RuntimeException.class)
    public R handlerValidException(RuntimeException e) {
//        log.error("运行时异常", e);
        return R.error(500,e.getMessage());
    }
}
